package com.tuo51.childcare.repository;

import com.tuo51.childcare.domain.dailyrecord.DailyGrowRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DailyGrowRecordRepository extends JpaRepository<DailyGrowRecord,String>, JpaSpecificationExecutor<DailyGrowRecord> {

    //@Query(value = "DELETE FROM tb_recipe WHERE food_id = ?1 AND recipe_type_id = ?2 AND DATE_FORMAT(recipe_date,'%Y-%m-%d') = ?3 AND area_id = ?4 ",nativeQuery = true)
    @Query(value = "select * from user_daily_observer WHERE uid = ?1 AND childrenId = ?2 AND day=?3",nativeQuery = true)
    List<DailyGrowRecord> findByUidAndChildrenIdAndGroupDate(String uid, String childrenId, String day);


    @Query(value = "select * from user_daily_observer " +
            "WHERE uid = ?1 AND childrenId = ?2 AND day=?3 and templateId in ?4", nativeQuery = true)
    List<DailyGrowRecord> findDailyValues(String uid, String childrenId, String day, List<String> templateIds);

    @Query(value = "select * from user_daily_observer " +
            "WHERE uid = ?1 AND childrenId = ?2 AND day=?3 and templateId = ?4", nativeQuery = true)
    List<DailyGrowRecord> findDailyValue(String uid, String childrenId, String day, String templateId);
}
